package com.yicheng.controller;

import com.yicheng.controller.utils.R;
import com.yicheng.entity.Kinds;
import com.yicheng.service.KindsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/kinds")
public class KindsController {

    @Autowired
    private KindsService kindsService;

    @GetMapping("/getKinds")
    public R getKinds(){
        R r = new R();
        try {
            List<Kinds> kindsList = kindsService.list();
            r.setList(kindsList);
            r.setMsg("获取社区图片种类成功");
        }catch (Exception e){
            r.setStatus(false);
            r.setMsg(e.getMessage());
        }
        return r;
    }
}
